<template>
  <div class="createSongSheet">
        <van-field v-model="name" label="歌单名" placeholder="请输入歌单名" />
    <div class="addBtn">
        <van-button @click="add" type="primary" round>{{this.$route.query.songSheetId?"修改":"添加"}}</van-button>
    </div>
  </div>
</template>

<script>
import { addSongSheet } from "@/api/songSheet.js"
export default {
name : "createdSongShoot",
data(){
    return {
        name : this.$route.query.name || '',
        songSheetId:this.$route.query.songSheetId || undefined,
    }
},
created(){

},
methods:{
    add(){      //添加歌单
        if(this.name.trim()==''){
            return this.$toast.fail('请填写歌单名!')
        }
        addSongSheet({
            name:this.name,
            songSheetId:this.songSheetId
        }).then(res=>{
            if(res.code==200){
                this.$toast.success(this.$route.query.songSheetId?'修改成功!':'添加成功!');
                this.$router.back(-1);
            }
        })
    }
},
}
</script>

<style lang="less" scoped>
.createSongSheet{
    width: 100%;
    .addBtn{
        background: white;
        padding: 20px 10px;
        /deep/.van-button{
            width: 100%;
        }
    }
}
</style>